package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.MovieType;
import com.woniu.cinema.service.MovieTypeService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 影片类型Controller
 * 
 * @author yy
 * @date 2022-03-30
 */
@RestController
public class MovieTypeController extends BaseController
{
    @Autowired
    private MovieTypeService movieTypeService;



    @GetMapping("web/cinema/movietype/list")
    public TableDataInfo weblist(MovieType movieType)
    {
        startPage();
        List<MovieType> list = movieTypeService.selectMovieTypeList(movieType);
        return getDataTable(list);
    }

    /**
     * 查询影片类型列表
     */
    @GetMapping("/cinema/movietype/list")
    public TableDataInfo list(MovieType movieType)
    {
        startPage();
        List<MovieType> list = movieTypeService.selectMovieTypeList(movieType);
        return getDataTable(list);
    }

    /**
     * 导出影片类型列表
     */
    @Log(title = "影片类型", businessType = BusinessType.EXPORT)
    @GetMapping("/cinema/movietype/export")
    public AjaxResult export(MovieType movieType)
    {
        List<MovieType> list = movieTypeService.selectMovieTypeList(movieType);
        ExcelUtil<MovieType> util = new ExcelUtil<MovieType>(MovieType.class);
        return util.exportExcel(list, "movietype");
    }

    /**
     * 获取影片类型详细信息
     */
    @GetMapping(value = "/cinema/movietype/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Integer typeId)
    {
        return AjaxResult.success(movieTypeService.selectMovieTypeById(typeId));
    }

    /**
     * 新增影片类型
     */
    @Log(title = "影片类型", businessType = BusinessType.INSERT)
    @PostMapping("/cinema/movietype")
    public AjaxResult add(@RequestBody MovieType movieType)
    {
        return toAjax(movieTypeService.insertMovieType(movieType));
    }

    /**
     * 修改影片类型
     */
    @Log(title = "影片类型", businessType = BusinessType.UPDATE)
    @PutMapping("/cinema/movietype")
    public AjaxResult edit(@RequestBody MovieType movieType)
    {
        return toAjax(movieTypeService.updateMovieType(movieType));
    }

    /**
     * 删除影片类型
     */
    @Log(title = "影片类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/cinema/movietype/{typeIds}")
    public AjaxResult remove(@PathVariable Integer[] typeIds)
    {
        return toAjax(movieTypeService.deleteMovieTypeByIds(typeIds));
    }
}
